package edu.neu.chenhan.fragment.cooperation;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import edu.neu.chenhan.R;
import edu.neu.chenhan.model.TrainingDetail;

public class TrainingDetailFragment extends Fragment {

    private TextView tvTrainingName, tvTrainingDate, tvTrainingLocation, tvTrainingOrganizer, tvTrainingSummary, tvTrainingObjectives, tvTrainingFee, tvTrainingFeeIncludes;
    private TrainingDetail training;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.activity_training_detail, container, false);

        tvTrainingName = view.findViewById(R.id.training_name);
        tvTrainingDate = view.findViewById(R.id.training_date);
        tvTrainingLocation = view.findViewById(R.id.training_location);
        tvTrainingOrganizer = view.findViewById(R.id.training_organizer);
        tvTrainingSummary = view.findViewById(R.id.training_summary);
        tvTrainingObjectives = view.findViewById(R.id.training_objectives);
        tvTrainingFee = view.findViewById(R.id.training_fee);
        tvTrainingFeeIncludes = view.findViewById(R.id.training_fee_includes);

        Bundle args = getArguments();
        if (args != null) {
            training = (TrainingDetail) args.getSerializable("training");
            if (training != null) {
                tvTrainingName.setText(training.getName());
                tvTrainingLocation.setText(training.getLocation());
                tvTrainingOrganizer.setText(training.getOrganizer());
                tvTrainingSummary.setText(training.getSummary());
                tvTrainingObjectives.setText(training.getObjectives());
                tvTrainingFeeIncludes.setText(training.getFeeIncludes());
            }
        }

        return view;
    }
}